#pragma once
#include <myFs/bitset.h>

namespace myFs {
namespace basic {

class Bitmap {
  public:
    Bitmap();
    Bitmap(void* baseptr, void* targetptr, size_t blocknum, size_t blocksize);
    void   init(void* baseptr, void* targetptr, size_t blocknum, size_t blocksize);
    size_t size() const;
    size_t usedBlock() const;
    size_t freeBlock() const;

    bool   hasAlloc(size_t inum) const;
    size_t alloc(size_t blknum = 1);
    void   dealloc(size_t blkid, size_t blknum = 1);

    void*  convertToAddr(size_t bnum) const;
    size_t blocksize() const;

  private:
    Bitset m_bitset;
    void*  m_targetptr;
    size_t m_blocksize;
};
}  // namespace basic
}  // namespace myFs